/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package db;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import vanScheduling.Permission;

/**
 *
 * @author Dan
 */
public class PermissionDAO extends DAOTest {

    public static List<Permission> getPermissions()
    {
        Connection con = getConnection();
        ArrayList<Permission> permissions = new ArrayList<Permission>();
        try {
            CallableStatement cs = con.prepareCall("{call stp_selAllPermissions}");
            ResultSet rs = cs.executeQuery();

            while (rs.next())
            {
                int id = rs.getInt("ID");
                String permissionLevel = rs.getString("PermissionLevel");
                permissions.add(new Permission(id, permissionLevel));
            }

            cs.close();
            con.close();
        }
        catch (SQLException e) {System.err.println(e.getMessage());e.printStackTrace();}
        return permissions;
    }

    
}
